package com.winshare.saleAssistant.controller;


import com.winshare.saleAssistant.model.SaleSynchronous;
import com.winshare.saleAssistant.service.ISaleSynchronousService;
import com.winshare.saleAssistant.util.LogicResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2020-12-11 14:46:24
 */
@Controller
@RequestMapping("/sys/saleSynchronous")
public class SaleSynchronousController   {

    @Autowired
    private ISaleSynchronousService saleSynchronousService;


    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return saleSynchronousService.list(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SaleSynchronous saleSynchronous) {
        saleSynchronousService.save(saleSynchronous);
        return LogicResponse.success("success");
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer saleSynchronousId) {
        saleSynchronousService.removeById(saleSynchronousId);
        return LogicResponse.success("success");
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SaleSynchronous saleSynchronous) {
        saleSynchronousService.updateById(saleSynchronous);
        return LogicResponse.success("success");
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{saleSynchronousId}")
    @ResponseBody
    public Object detail(@PathVariable("saleSynchronousId") Integer saleSynchronousId) {
        return saleSynchronousService.getById(saleSynchronousId);
    }
}
